use "SLAConfirmationHearingsData.dta"

* NOTE: Data for O'Connor to Kagan originally provided by Dion Farganis and Justin Wedeking
* NOTE: Data for Gorsuch provided by Ryan Owens and Justin Wedeking
* NOTE: Data for Kavanaugh provided by Jessica Schoenherr, Elizabeth Lane, and Miles Armaly

*************************
*** descriptive stats ***
*************************

* difference in question-asking habits, in-party vs. out-party (para 7, data and measures)
ttest question, by(inParty)

*** GPR:
* 1 = Out/Unified
* 2 = In/Divided
* 3 = Out/Divided
* 4 = In/Unified

***************************************
*** THE MAIN MODEL FOR THE REVISION ***
***************************************

nbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney, cluster(order_of_nomination)
est store nbreg
estat ic

******************************************
*** STATISTICAL TESTS FOR THE REVISION ***
******************************************

**************
*** groups ***
**************

*** FIRST PARAGRAPH AFTER TABLE IN TEXT - In v. In ****
est restore nbreg
margins, at(gpr=(2) attorney=(1)) ///
at(gpr=(4) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

*** SECOND PARAGRAPH AFTER TABLE IN TEXT - Out v. Out ***
est restore nbreg
margins, at(gpr=(1) attorney=(1)) ///
at(gpr=(3) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

*** THIRD PARAGRAPH AFTER TABLE IN TEXT - In Unified v. Out Unified ***
est restore nbreg
margins, at(gpr=(1) attorney=(1)) ///
at(gpr=(4) attorney=(1))  vce(unconditional) post
test _b[1._at] = _b[2._at]

*** THIRD PARAGRAPH AFTER TABLE IN TEXT - In Divided v. Out Divided ***
est restore nbreg
margins, at(gpr=(2) attorney=(1)) ///
at(gpr=(3) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

**********************
*** public opinion ***
**********************

*** TOP LEFT - OUT-DIVIDED ***
est restore nbreg
margins, at(gpr=(3) pubOpin=(53) attorney=(1)) ///
at(gpr=(3) pubOpin=(90) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

*** BOTTOM LEFT - IN-DIVIDED ***
est restore nbreg
margins, at(gpr=(2) pubOpin=(53) attorney=(1)) ///
at(gpr=(2) pubOpin=(90) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

*** TOP RIGHT - OUT-UNIFIED ***
est restore nbreg
margins, at(gpr=(1) pubOpin=(53) attorney=(1)) ///
at(gpr=(1) pubOpin=(90) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

*** BOTTOM RIGHT - IN-UNIFIED ***
est restore nbreg
margins, at(gpr=(4) pubOpin=(53) attorney=(1)) ///
at(gpr=(4) pubOpin=(90) attorney=(1)) vce(unconditional) post
test _b[1._at] = _b[2._at]

********************
*** For Figure 3 ***
********************
est restore nbreg
margins, atmeans at(gpr = 1 pubOpin=(53(1)90) attorney=(1)) vce(unconditional) 

est restore nbreg
margins, atmeans at(gpr = 2 pubOpin=(53(1)90) attorney=(1)) vce(unconditional) 

est restore nbreg
margins, atmeans at(gpr = 3 pubOpin=(53(1)90) attorney=(1)) vce(unconditional) 

est restore nbreg
margins, atmeans at(gpr = 4 pubOpin=(53(1)90) attorney=(1)) vce(unconditional) 

***********************************
*** THE MODELS FOR THE APPENDIX ***
***********************************

* 1 - model in the paper
nbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney, cluster(order_of_nomination)
est store original
estat ic

* 2 - time counter
nbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney time, cluster(order_of_nomination)
est store time
estat ic

* 3 - time squared
nbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney time2, cluster(order_of_nomination)
est store timesq
estat ic

* 4 - polarization
nbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney polarization, cluster(order_of_nomination)
est store polarization
estat ic

* 5 - fixed effects
menbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney || order_of_nomination:
est store fe
estat ic

* 6 - controversy
nbreg question i.gpr##c.pubOpinPreHearing timetoelec nominate_distance qualifications percentOpposed attorney control, cluster(order_of_nomination)
est store controversy
estat ic

*****************************
*** GORSUCH AND KAVANAUGH ***
*****************************

* do not save after this step! It will only keep groups 1 and 4

ttest question if gpr == 4, by(postGarland)
ttest question if gpr == 1, by(postGarland)
ttest question if postGarland == 1, by(gpr)
drop if gpr == 2
drop if gpr == 3
ttest question if postGarland == 0, by(gpr)
